package cn.lhx.blog.util;

import java.util.Calendar;
import java.util.Date;

public class TimeTookit2 {
	
	public static String getMonth(Date date){
		StringBuilder sb=new StringBuilder();
		Calendar calendar=Calendar.getInstance();
		calendar.setTime(date);
		
		int month=calendar.get(Calendar.MONTH);//月重0开始
			sb.append((month+1)+"");
		return sb.toString();
		
	}
	
	
	/**
	 * 格式年
	 * @param date
	 * @param style
	 * @return
	 */
	public static String getYear(Date date){
		StringBuilder sb=new StringBuilder();
		Calendar calendar=Calendar.getInstance();
		calendar.setTime(date);
		int year=calendar.get(Calendar.YEAR);
		int month=calendar.get(Calendar.MONTH);//月重0开始
		int day=calendar.get(Calendar.DAY_OF_MONTH);
			sb.append(year+"");
		return sb.toString();
		
	}
	public static void main(String[] args) {
		System.out.println(""+TimeTookit2.getYear(new Date())+TimeTookit2.getMonth(new Date()));
	}
}
